#include<iostream>
using namespace std;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		for (int i = 0; i < n / 2 + 1; i++) {
			for (int j = 0; j < i; j++) {	
				cout << " ";
			}
			cout << "X";
			for (int j = 0; j < 2 * i + 1; j++) {
				cout << " ";
			}
			cout << "X" << endl;
			for (int j = 0; j < i; j++) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}